<template>
  <div>
    <div v-for="item in props.arr" :key="item.code">
    <div :class="{tap: item.code==props.current}" @click="radioChange(item.code)" class="option">{{item.code}}. {{item.option}}</div>
    </div>
  </div>
</template>

<script setup>
  import { defineProps, defineEmits } from 'vue'
  const props = defineProps({
    arr: { type: Array },
    current: { type: String }
  })
  // 使用defineEmits注册一个自定义事件
  const emit = defineEmits(['fnc'])

  // 点击事件触发emit，去调用我们注册的自定义事件getValue,并传递value参数至父组件
  const radioChange = (code) => {
    emit('fnc', code)
  }
</script>

<style lang="less" scoped>
  .tap {
    background-color: rgba(0, 128, 0, .5);
  }
  .option {
    padding-left: 5vw;
    line-height: 5vh;
    margin-bottom: 1vh;
  }
</style>
